package org.cheetahworkflow.designer.model;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

public class RapidView {
	
	public String nodeType;
	
	public String caption;
	
	public String description;
	
	public String mappingClass;
	
	public String parameter;
	
	public String ref;
	
	public String refClasspath;
	
	public String defaultCondition;
	
	private Rectangle hostBounds;
	
	private Chart chart;
	
	public RapidView(SequenceNode node) {
		hostBounds = new Rectangle(node.getLocation(), node.getSize());
		nodeType = "Sequence";
		caption = node.getCaption();
		description = node.getDescription();
		mappingClass = node.getClassName();
		parameter = node.getParameter();
	}
	
	public RapidView(SwitchNode node) {
		hostBounds = new Rectangle(node.getLocation(), node.getSize());
		nodeType = "Switch";
		caption = node.getCaption();
		description = node.getDescription();
	}
	
	public RapidView(ModuleNode node) {
		hostBounds = new Rectangle(node.getLocation(), node.getSize());
		nodeType = "Module";
		caption = node.getCaption();
		description = node.getDescription();
		ref = node.getRef();
		refClasspath = node.getClasspath();
	}
	
	public RapidView(StartNode node) {
		hostBounds = new Rectangle(node.getLocation(), node.getSize());
		nodeType = "Start";
		caption = StartNode.START_NODE_TEXT;
		description = "Indicates the start of current workflow.";
	}
	
	public RapidView(EndNode node) {
		hostBounds = new Rectangle(node.getLocation(), node.getSize());
		nodeType = "End";
		caption = EndNode.END_NODE_TEXT;
		description = "Indicates the end of current workflow.";
	}
	
	public RapidView(ConditionArrow arrow, Point startPoint) {
		hostBounds = new Rectangle(startPoint.x, startPoint.y, 0, 0);
		nodeType = "Condition Arrow";
		mappingClass = arrow.getClassName();
		parameter = arrow.getParameter();
		defaultCondition = arrow.isDefault() ? "true" : "false";
	}

	public Rectangle getHostBounds() {
		return hostBounds;
	}
	
	public void setChart(Chart chart) {
		this.chart = chart;
	}
	
	public Chart getChart() {
		return chart;
	}
}
